/**
 * @param {string[]} strs
 * @return {string[][]}
 */
 var groupAnagrams = function(strs) {
  var map = {}
  for(var i=0;i<strs.length;i++) {
      var key = strs[i].split('').sort().join()
      if (key in map) {
          map[key].push(strs[i])
      } else {
          map[key] = [strs[i]]
      }
  }
  return Object.values(map)
};

var result = groupAnagrams(["eat", "tea", "tan", "ate", "nat", "bat"])
console.log(result)